/**
 * @Author: 李文浩
 * @Date: 2019/8/15
 * @Last Modified by: 焦质晔
 * @Last Modified time: 2019-11-14 18:57:55
 */
import axios from '@/api/fetch'
import * as types from './types'
import SERVER from '@/api/server'

// 维修项目车型组下拉列表
export const findProjectModelList = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/findProjectModelList`, {
params})

// 维修项目主类下拉列表
export const findMainGroup = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/findMainGroup`, {
params})

// 维修项目查询工种
export const findTechnicianWorkType = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/order/repair/querytechnicianWorkType/item`, {
params})

// 维修类型查询
export const searchRepairType = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedataRepairtypes/queryList`, {
params})

// 维修清单维修类型
export const findListRepairType = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedataRepairtypes/findListRepairType`, {
params})

// 维修项目树
export const findLabourTree = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/findRepairProjectTree`, {
params})

// 维修项目备件查询
// export const findLabourPart=(modelLabourCodes,labourCodes,downTag,params)=>axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/findRepairProjectItem2/${modelLabourCodes}/${labourCodes}/${downTag}/0`,{params})
export const findLabourPart = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/findRepairProjectItem2/${params.labourId}/${params.modelLabourCodes}/${params.labourCodes}/${params.downTag}/0`, {})

// 维修项目/备件保存
export const btnSave = params => axios.post(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/btnSave`, params)

// 维修项目新增
export const addLabour = params => axios.post(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/btnLabour`, params)

export const findLabourList = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/findRepairProjectList3`, {
params})

// 维修项目二级分类查询
export const getSubGroupList = (mainGroupCode, params) => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/labourgroups/${mainGroupCode}/subgroups`, {
params})

// 维修项目主类新增
export const addMainGroup = params => axios.post(`${SERVER.DMSCLOUD_REPAIR}/basedata/labourgroups`, {
params})

// 维修项目二级分类新增
export const addSubGroup = (mainGroupCode, params) => axios.post(`${SERVER.DMSCLOUD_REPAIR}/basedata/labourgroups/${mainGroupCode}/subgroups`, {
params})

// 维修项目主类修改
export const editMainGroup = (mainGroupCode, params) => axios.put(`${SERVER.DMSCLOUD_REPAIR}/basedata/labourgroups/${mainGroupCode}`, {
params})

// 维修项目二级分类修改
export const editSubGroup = (subGroupCode, params) => axios.put(`${SERVER.DMSCLOUD_REPAIR}/basedata/labourgroups//${subGroupCode}/subgroups`, {
params})

// 维修项目主类 单查询
export const getMainGroup = (mainGroupCode, params) => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/labourgroups/${mainGroupCode}`, {
params})

// 维修项目二级分类 单查询
export const getSubGroup = (subGroupCode, params) => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/labourgroups/${subGroupCode}/subgroupsinfo`, {
params})

// 单项复制查询是否有重复
export const findExistLabour = (modelLabourCode, labourCode, params) => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/queryModelLabourAllEntity/${modelLabourCode}/${labourCode}`, {
params})

// 单项复制
export const singleCopy = params => axios.post(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/btnSingleCopy`, params)

// 全部复制
export const allCopy = params => axios.post(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/btnAllCopy`, params)

// 获取备件数据列表
export const getqueryInsteadPartList = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/order/repair/addPart/queryInsteadPart/${params.PART_NO}`, {
params})

// 查询关联维修项目
export const getqueryRelatedItemsList = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/findRepairItemRelation`, {
params})

// 保存关联维修项目
export const saveRelation = params => axios.post(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/saveRelation`, params)

// 保存关联备件
export const savePart = params => axios.post(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/btnPart`, params)

// 删除项目
export const delteLabour = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/delteLabour`, {
params})

// 删除项目
export const deletePart = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/deltePart`, {
params})

// 生成维修项目代码
export const generateLabourCode = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/generateLabourCode`, {
params})

// 导出1
export const exportData = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/exportRepairProject`, {
  params,
  responseType: 'arraybuffer'
})

// 导出2
export const exportData1 = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/exportRepairPart/${params.labourId}/${params.modelLabourCodes}/${params.labourCodes}/${params.downTag}/0`, {
  params,
  responseType: 'arraybuffer'
})

// 下载模板1
export const repairProject = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/repairProjectDownload`, {
  params,
  responseType: 'arraybuffer'
})

// 下载模板2
export const repairPart = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/repairPartDownload`, {
  params,
  responseType: 'arraybuffer'
})

// 下载模板3
export const repairMouhour = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/importRepairAbleController/importWorkingHours`, {
  params,
  responseType: 'arraybuffer'
})

// 导出工时费
export const exportLabourFee = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/importRepairAbleController/queryOwnerInfoExport`, {
  params,
  responseType: 'blob'
})
